package com.tms.carriermangement.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.carriermangement.domain.Carriermangement;
import com.tms.carriermangement.service.ICarriermangementService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 承运商管理Controller
 *
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/carriermangement")
public class CarriermangementController extends BaseController
{
    @Autowired
    private ICarriermangementService carriermangementService;

    /**
     * 查询承运商管理列表
     */
    @RequiresPermissions("carriermangement:carriermangement:list")
    @GetMapping("/list")
    public TableDataInfo list(Carriermangement carriermangement)
    {
        startPage();
        List<Carriermangement> list = carriermangementService.selectCarriermangementList(carriermangement);
        return getDataTable(list);
    }

    /**
     * 导出承运商管理列表
     */
    @RequiresPermissions("carriermangement:carriermangement:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Carriermangement carriermangement)
    {
        List<Carriermangement> list = carriermangementService.selectCarriermangementList(carriermangement);
        ExcelUtil<Carriermangement> util = new ExcelUtil<Carriermangement>(Carriermangement.class);
        util.exportExcel(response, list, "承运商管理数据");
    }

    /**
     * 获取承运商管理详细信息
     */
    @RequiresPermissions("carriermangement:carriermangement:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(carriermangementService.selectCarriermangementById(id));
    }

    /**
     * 新增承运商管理
     */
    @RequiresPermissions("carriermangement:carriermangement:add")
    @PostMapping
    public AjaxResult add(@RequestBody Carriermangement carriermangement)
    {
        return toAjax(carriermangementService.insertCarriermangement(carriermangement));
    }

    /**
     * 修改承运商管理
     */
    @RequiresPermissions("carriermangement:carriermangement:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody Carriermangement carriermangement)
    {
        return toAjax(carriermangementService.updateCarriermangement(carriermangement));
    }

    /**
     * 删除承运商管理
     */
    @RequiresPermissions("carriermangement:carriermangement:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(carriermangementService.deleteCarriermangementByIds(ids));
    }
}
